package com.cj.demo6.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;


@Component
@Slf4j
public class MyObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("新增自动填充");
        this.setFieldValByName("insertTime",new Date()+"",metaObject);
        this.setFieldValByName("updateTime",new Date().getTime()+"",metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("新增自动填充");
        this.setFieldValByName("updateTime",new Date().getTime()+"",metaObject);
    }
}
